package org.java.user.controller;

import org.java.commons.vo.Result;
import org.java.user.api.damain.Role;
import org.java.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private UserService userService;
    //获取所有角色的数据
    @GetMapping
    public List<Role> get(){
        return this.userService.findAllRoles();
    }
    //保存角色
    @PostMapping
    public Result save(@RequestBody Role role){
        return this.userService.save(role);
    }
    //根据ID删除
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable("id") String id){
        return this.userService.deleteRole(id);
    }
}
